/**
 * action类型
 *
 * @author CT
 * @email 994599447@qq.com
 * @date 2017.8.21
 */
'use strict';
import * as types from './actionTypes'
import Util from '../common/utils'
import * as urls from '../common/serverUrl'
import * as Storage from '../common/storage'
import * as config from '../config/appConfig'

//倒计时数据
export const remindDatas = () => {
    return (dispatch) => {
        Storage.getAllData(config.StorageKey.RemindDate)
        .then( data => {
            if(!data || data == ''){
                dispatch({type: types.kRemindDatas,remindDatas: data,isData: false});
            }else{
                dispatch({type: types.kRemindDatas,remindDatas: data,isData: true});
            }
        });
      }
};

//置顶倒计时
export const atTopRemindData = () => {
    return (dispatch) => {
        Storage.load(config.StorageKey.AtTopId)
        .then( data => {
            if(data && data != ''){
                Storage.loadForKeyId(config.StorageKey.RemindDate,data)
                .then( rdData => {
                    if(rdData && rdData != '' && rdData != 'NotFoundError'){
                        dispatch({type: types.kAtTopRemindData,atTopRemindData: rdData});
                    }else{
                        dispatch({type: types.kAtTopRemindData});
                    }
                });
            }else{
                dispatch({type: types.kAtTopRemindData});
            }
        });
      }
};